//
//  UserAccountViewModal.swift
//  XLWB
//
//  Created by 郭亮 on 16/3/16.
//  Copyright © 2016年 gl. All rights reserved.
//

import UIKit

class UserAccountViewModal: NSObject {
    
    var accessToken: AccessTokenItem?
    
    var isLogin: Bool {
    return accessToken != nil && !isExpire
    }
    
    var isExpire: Bool {
        guard let expires_date = accessToken?.expires_date else {
        return true
        }
        return expires_date.compare(NSDate()) == NSComparisonResult.OrderedAscending
    }
    
    //单例
    static let shareInstance: UserAccountViewModal = UserAccountViewModal()
    
    override init() {
        //取出对象
        accessToken = NSKeyedUnarchiver.unarchiveObjectWithFile(caches_AccessToken) as? AccessTokenItem
    }
}
